<template>
	<view @click="Jump('/pages/mine/address/address?isSelect=true')">
		<m-block gap="0 24">
			<view class="block_item flex-between" v-if="nowId&&address">
				<view>
					<view class="h1">{{address.are}}</view>
					<view class="h2">{{address.useraddress}}</view>
					<view class="h3 flex">
						<view class="name">
							<text>{{address.username}}</text>
						</view>
						<view class="phone">
							<text>{{address.userphone}}</text>
						</view>
						<view v-if="address.isdefualt==1">
							<uni-tag text="默认" type="error" size="mini"></uni-tag>
						</view>
						<view v-if="address.tag" class="ml-8">
							<uni-tag :text="address.tag" type="primary" size="mini"></uni-tag>
						</view>
					</view>
				</view>
				<view @click.stop="Jump('/pages/mine/address/editor_address/editor_address?id='+address.id)">
					<m-icon size="36" color="#C0C0C0" type="icon-bianji"></m-icon>
				</view>
			</view>
			<view class="no-address" v-else>
				<text>+ 添加收货地址</text>
			</view>
		</m-block>
	</view>
</template>

<script>
	import { mapState } from 'vuex'
	export default {
		name: "m-address",
		data() {
			return {
				list: [],
			};
		},
		props: {
			sAddress: {
				type: Object,
				default: () => {},
			},
		},
		mounted() {

		},
		computed: {
			...mapState({
				nowId: state => state.address.nowId,
				addressList: state => state.address.addressList,
			}),
			address() {
				let info = this.addressList.filter(item => {
					console.log(item)
					return item.id == this.nowId
				})
				return info[0];
			},

		}
	}
</script>

<style lang="scss">
	.block_item {
		padding: 23rpx 0rpx;
		border-bottom: 1rpx solid #F5F5F5;

		.h1 {
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #999999;
		}

		.h2 {
			padding: 10rpx 0;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
		}

		.h3 {
			.name {
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
			}

			.phone {
				padding: 0 15rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #999999;
			}

		}
	}

	.no-address {
		font-size: 28rpx;
		font-family: PingFang TC;
		font-weight: 500;
		color: #333;
		padding: 60rpx 0;
		text-align: center;
	}
</style>